<!-- BEGIN: website -->
<script type="text/javascript">
	$(function (){
		$(".tab_content").hide(); //Hide all content
		$("ul.tabs li:first a").addClass("active").show(); //Activate first tab
		$(".tab_content:first").show(); //Show first tab content

		$('#product_info_tabs li').each(function (){
			
			$('#product_info_tabs li a').click(function (){
				$("ul.tabs li a").removeClass("active");
				$(".tab_content").hide();
				$('#'+$(this).attr('id')+'_content').css('display', '');
				$(this).addClass('active');
				return false;
			});
			
		});
	});
function upload(){
	$('#ajax-loader').show();
	$.ajaxFileUpload({
		url:'site/website/uploadimg.php',
		fileElementId:'fileToUpload',
		dataType: 'json',
		success: function (data){
			if(data.img==true){
				//$('row-first');
				$strHtml = '<tr>'
							+'<td><img src="{baseUrl}/media/website/banner/'+data.file+'" width="200px" height="75px" /></td>'
							+'<td><input type="checkbox" name="banner[left][]" value="'+data.imgid+'" /></td>'
							+'<td class="a-center"><input type="checkbox" name="banner[right][]" value="'+data.imgid+'" /></td>'
							+'<td><input type="checkbox" name="banner[delete][]" value="'+data.imgid+'" /><input type="hidden" name="product[idimg][]" value="'+data.imgid+'" /></td>'
						+'</tr>';
				$($strHtml).insertAfter('#row-first');
				$('#ajax-loader').hide();
			}else{
				switch (data.file){
					case 2: {alert('File quá lớn');loaded();} break;
					case 1: {alert('Không cho phép file này');loaded();} break;
					default: {
						$('#ajax-loader').hide();
					} break;
				}
			}
			return true;
		},
		error: function(){
			alert('Không thể upload file');
			$('#ajax-loader').hide();
		}
	});
}
function uploadbackground(){
	$('#ajax-loader').show();
	$.ajaxFileUpload({
		url:'site/website/uploadbackground.php',
		fileElementId:'imgbackground',
		dataType: 'json',
		success: function (data){
			if(data.img==true){
				//$('row-first');
				$strHtml = '<img src="{baseUrl}/media/website/background/'+data.file+'" width="50px" height="50px" /><a href="javascript:void(0)" class="color-img-delete" onclick="deleteImg(\''+data.file+'\')" ></a>';
				$('#background-img').html($strHtml);
				$('#ajax-loader').hide();
			}else{
				switch (data.file){
					case 2: {alert('File quá lớn');loaded();} break;
					case 1: {alert('Không cho phép file này');loaded();} break;
					default: {
						$('#ajax-loader').hide();
					} break;
				}
			}
			return true;
		},
		error: function(){
			alert('Không thể upload file');
			$('#ajax-loader').hide();
		}
	});
}
function deleteImg(img_name){
	$.ajax({
		url	:'site/website/deleteimg.php',
		type:'POST',
		data:{img_name:""+img_name+""},
		dataType:'json',
		beforeSend:function(){
			$("#ajax-loader").show();
		},
		success:function(msg){
			$("#ajax-loader").hide();
			if(msg.msg){
				$('#background-img').html('<input id="imgbackground" type="file" onchange="uploadbackground()" name="imgbackground">');
			}		
		}
	});
}
</script>
<div id="main-left">
	<div class="menu">
		<h2>Thông tin website</h2>
		<ul id="product_info_tabs" class="tabs">
			<li>
				<a id="product_tabs_1" class="tab-item-link active" href="#"><span>Banners</span></a>
			</li>
			<li>
				<a id="product_tabs_2" class="tab-item-link" href="#"><span>Liên hệ</span></a>
			</li>
			<li>
				<a id="product_tabs_3" class="tab-item-link" href="#"><span>Tài khoản</span></a>
			</li>
			
			<li>
				<a id="product_tabs_4" class="tab-item-link" href="#"><span>Background</span></a>
			</li>
			<li>
				<a id="product_tabs_5" class="tab-item-link" href="#"><span>Số người truy cập</span></a>
			</li>
		</ul>
	</div>
</div>

<div id="content">
	<form <form enctype="multipart/form-data" method="post" name="frm">
		<div class="content-header h_title">
			<h2>Thông tin website</h2>
			<div class="content-buttons">
				<input type="submit" value="Lưu" class="button" />
			</div>
			<div class="clr"></div>
		</div>
		<div id="product_tabs_1_content" style="display:none" class="tab_content">
			<div class="grid">
				<table id="productGrid_table" class="data" cellspacing="0">
					<thead>
						<tr class="headings">
							<th width="55%">Ảnh</th>
							<th width="20%">Banner left</th>
							<th width="20%">Banner right</th>
							
							<th width="5%">Xóa</th>
						</tr>
					</thead>
					<tbody>
                    	<!-- BEGIN: list -->
                        <tr>
							<td><img src="{baseUrl}{list.img}" width="200px" height="75px" /></td>
							<td><input type="checkbox" name="banner[left][]" value="{list.banner_id}" {list.chkleft}/></td>
							<td class="a-center"><input type="checkbox" name="banner[right][]" value="{list.banner_id}" {list.chkright}/></td>
							<td><input type="checkbox" name="banner[delete][]" value="{list.banner_id}" /></td>
						</tr>
                        <!-- END: list -->
                    	<tr id="row-first">
                        </tr>
						<tr>
							<td colspan="4">
                            	<input id="fileToUpload" type="file" onchange="upload()" name="uploadimage">
                            </td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
		<div id="product_tabs_2_content" style="display:none;" class="tab_content">
			<textarea class="mceEditor editor contact_content " cols="50" rows="5" name="contact_content" style=" width:100%; height:40em;">{contact_content}</textarea>
		</div>
		<div id="product_tabs_3_content" style="display:none;" class="tab_content">
			<table class="form-list" cellspacing="0">
				<tbody>
					<tr>
						<td class="label">
							<label for="product_name">Yahoo</label>
						</td>
						<td class="value">
							<input type="text" name="yahoo" class="input-text input-text-medium" value="{yahoo}" />
						</td>
					</tr>
					<tr>
						<td class="label">
							<label for="product_name">Sky</label>
						</td>
						<td class="value">
							<input type="text" name="sky" class="input-text input-text-medium" value="{sky}" />
						</td>
					</tr>
					<tr>
						<td class="label">
							<label for="product_name">Link tới FaceBook</label>
						</td>
						<td class="value">
							<input type="text" name="fb" class="input-text input-text-medium" value="{fb}" />
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div id="product_tabs_4_content" style="display:none;" class="tab_content">
			<div id="background-img">
				<!-- BEGIN: BACKGROUND -->
				<img src="{baseUrl}/media/website/background/{background}" width="50px" height="50px" /><a href="javascript:void(0)" class="color-img-delete" onclick="deleteImg('{background}')" ></a>
				<!-- END: BACKGROUND -->
				<!-- BEGIN: UPLOADBACKGROUND -->
				<input id="imgbackground" type="file" onchange="uploadbackground()" name="imgbackground">
				<!-- END: UPLOADBACKGROUND -->
			</div>
		</div>
		<div id="product_tabs_5_content" style="display:none;" class="tab_content">
			Số người truy cập: {counter} (người).
		</div>
		<ul class="list-error">
			{error}
		</ul>
	</form>
</div>
<!-- END: website -->